<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>MARC Login</title>
	
	<link rel="stylesheet" href="styles/marc.css" />
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
	<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
	
	<script type="text/javascript">
	$(document).ready(function()
	{		
		$('#loginForm').submit(function(e)
		{
			e.preventDefault();
			
			var _userid = $('#enteredUserID').val();
			var _enteredPW = $('#enteredPassword').val();
			
			//Send the userid to UserInfoService for authentication
			$.ajax({ 
		  	  	url:"/marc/UserInfoService",
				type:'POST',
				data: {
					'method': "AuthenticateUser",
					'userid': _userid,
					'enteredPass': _enteredPW
				},
				dataType:"json",
				//if it comes back successfully, load the plugin
				success: function(html) 
				{
					$('#globalSettings').data('userData',html["User"]);
					if(html["validLogin"] == false)
					{
						alert("Sorry, that login was incorrect. Please try again.");
					}
					else
					{
						setCookie("userlogin", _userid, 1);
						window.location = "./";
					}
				},
				//otherwise, notify the user to of an error
				error: function(html){
					alert("An error occured while gathering user information." +
							"\nPlease refresh your browser and try again." +
							"\n\nIf problem persists please contact BigHelp Ministries");
				}
			});
		});
		
		function setCookie(c_name,value,exdays)
		{
			var exdate=new Date();
			exdate.setDate(exdate.getDate() + exdays);
			var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
			document.cookie=c_name + "=" + c_value;
		}
	});
	</script>
</head>
<body>
	<div id="headerDiv">
		<h1>
			MARC - St. James LifeTeen
			<a id="logo" href="./" target="_top"><img src="img/marc_logo.jpg" height="100px" /></a> 
		</h1>
		<hr />
	</div>
	<div class="loginBody">
		<p id="loginText">
			<h2>Welcome to MARC</h2> the Meeting Attendance, Registration, and Collaboration portal!<br>
			This site is still in development, however if you have been asked to visit it, <br>
			please feel free to log in below and take a look around. We hope to have the MARC system <br>
			fully functional by the end of 2012.
		</p> <br>
		<form id="loginForm" method="POST">
			<p align="center">
				User ID: <input type="text" id="enteredUserID" size="20" /><br />
				Password: <input type="password" id="enteredPassword" size="20" /><br />
				<input type="submit" id="loginFormSubmit" value="Login" />
			</p>
		</form>
	</div>
</body>
</html>